package lib.window;

import lib.Ffi;

/**
 * 还不错
 */
class Win {
	/**
	 * 编写一个提示框
	 * @param	txt 内容
	 * @param	caption 标题
	 */
	public static function msgbox(txt:String, caption:String = "提示"):Int {
		var _MessageBoxA = Ffi.getDef("MessageBoxA");
		return _MessageBoxA(null, txt, caption, 0);
	}

	/**
	 * 显示窗口
	 * @param hwnd 窗口句柄
	 * @param ConstSW SW常量
	 * @return Bool 返回成功是否
	 */
	public static function show(hwnd:Int, ConstSW:Int):Bool {
		var _ShowWindow = Ffi.getDef("ShowWindow");
		return _ShowWindow(hwnd, ConstSW);
	}

	public static function __init__():Void {
		Ffi.cdef("
			int MessageBoxA(void *w, const char *txt, const char *cap, int mtype);
			int SendMessage(int hwnd, int msg, int wParam, int lParam);
			bool ShowWindow(int hwnd, int msg, int cmd);
			bool DestroyWindow(int hWnd);
		");
	}
}

/**
 * SW常量
 */
@:enum abstract SW(Int) {
	/**
	 * hide and remember the show state
	 */
	var SW_HIDE = 0;

	/**
	 * revert to normal state and activate (do nothing if already in normal state)
	 */
	var SW_SHOWNORMAL = 1;

	/**
	 * minimize but do not deactivate (do nothing if already minimized)
	 */
	var SW_SHOWMINIMIZED = 2;
	var SW_SHOWMAXIMIZED = 3; // maximize and activate (do nothing if already maximized)
	var SW_SHOWNOACTIVATE = 4; // revert to normal state but do not activate (do nothing if alread in normal state)
	var SW_SHOW = 5; // show in current state and activate (activate even if minimized; do nothing if already visible)
	var SW_MINIMIZE = 6; // minimize and deactivate (do nothing if already minimized); same as SW_SHOWMINNOACTIVE
	var SW_SHOWMINNOACTIVE = 7; // minimize and deactivate; same as SW_MINIMIZE
	var SW_SHOWNA = 8; // show in current state but do not activate
	var SW_RESTORE = 9; // restore to last state (minimized -> normal or maximized; maximized -> normal) and activate
	var SW_SHOWDEFAULT = 10; // show per STARTUPINFO
	var SW_FORCEMINIMIZE = 11; // minimize from a different thread
}
